import React, { useRef, useState } from 'react'

function Child1 () {
  const [ str, setStr] = useState('child1')
  return (
    <div>
      child1
    </div>
  )
}
function App() {
  const inputRef = useRef()
  const child1Ref = useRef()
  const getData = () => {
    console.log(inputRef.current.value)
    console.log(child1Ref)
  }
  return (
    <div>
      <input type="text" ref = { inputRef } onChange = { getData }/>
      {/* 使用ref 在组件上时，子组件必须是 类组件 */}
      {/* <Child1 ref = { child1Ref }/> */}
    </div>
  )
}

export default App
